package com.cfuture.xiaozhi.smarthome.ui;

import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.cfuture.xiaozhi.smarthome.R;
import com.cfuture.xiaozhi.smarthome.adapter.LeftMenuListAdapter;

public class LeftMenuFragment extends Fragment implements OnItemClickListener {
	private Typeface typeface;
	private ListView lvSelect;
	private LeftMenuListAdapter menuAdapter;
	private Context mContext;
	public String[] data = { "日光灯", "窗帘", "空调风量", "空调温度", "电器开关" };

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// return inflater.inflate(R.layout.list, null);
		mContext = getActivity();
		View myView = inflater.inflate(R.layout.left_menu_frame, null);
		lvSelect = (ListView) myView.findViewById(R.id.left_menu_lv);
		menuAdapter = new LeftMenuListAdapter(mContext, data);
		lvSelect.setAdapter(menuAdapter);
		lvSelect.setOnItemClickListener(this);

		return myView;

	}

	private void switchFragment(Fragment fragment, String title) {
		if (getActivity() == null)
			return;
		if (getActivity() instanceof MainContentActivity) {
			MainContentActivity fca = (MainContentActivity) getActivity();
			fca.switchContent(fragment, title);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * android.widget.AdapterView.OnItemClickListener#onItemClick(android.widget
	 * .AdapterView, android.view.View, int, long)
	 */
	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		// view.findViewById(id)
		// switchFragment(fragment, title)
	}

}
